package cn.practice._07springaop.aop;

import org.springframework.stereotype.Component;

/**
 * 实现类
 */
@Component
public class CalculatorImpl implements Calculator{
    public int add(int x, int y) {
        if (x<0){
            throw new RuntimeException("x不能为负数");
        }

        int result = x+y;
        System.out.println("add:"+result);
        return result;
    }

    public int div(int x, int y) {
        int result = x/y;
        System.out.println("div:"+result);
        return result;
    }

    public int mul(int x, int y) {
        int result = x*y;
        System.out.println("mul:"+result);
        return result;
    }

    public int sub(int x, int y) {
        int result = x-y;
        System.out.println("sub:"+result);
        return result;
    }
}
